﻿using DAL;
using Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace Shop.Web.Controllers
{
    public class UserController : Controller
    {
        // GET: User
        /// <summary>
        /// 用户首页
        /// </summary>
        /// <returns></returns>
        public ActionResult Index()
        {
            string CustName = User.Identity.Name;
            if (CustName == string.Empty)
            {
                return Redirect("/Login/Index");
            }
            else
            {
                Customer cust = CustomerService.GetCustomer(CustName);
                return View(cust);
            }
        }
        /// <summary>
        /// 修改用户信息
        /// </summary>
        /// <param name="Id"></param>
        /// <param name="CustName"></param>
        /// <param name="Birthday"></param>
        /// <param name="Phone"></param>
        /// <returns></returns>
        public ActionResult Update(int Id, string CustName,DateTime Birthday,string Phone,string Sex)
        {
            int a = CustomerService.Update(Id, CustName,Birthday,Phone, Sex);
            if (a>0)
            {
                return Json(new { Success=true,Message="修改成功"});
            }
            else
            {
                return Json(new { Success = false , Message = "修改失败" });
            }
        }

        
        
    }
}